import java.util.Arrays;

public class Nm {
    //算法题：求和为s的两个数字；
    public static int[] fun(int[] array,int s){
        int left=0;
        int right= array.length-1;
        while(left<right){
            int sum=array[left]+array[right];
            if(sum>s){
                right--;
            } else if (sum<s) {
                left++;
            }else{
                return new int[]{array[left],array[right]};
            }
        }
        return new int[]{0};
    }
    public static void main(String[] args){
        int[] array={2,11,7,15};
        int s=9;
        int[] ret=fun(array,s);
        System.out.println(Arrays.toString(ret));
    }
}
